package ControlLayer;
import java.util.ArrayList;
import ModelLayer.*;

/**
 * Item ctr class that gathers information from the UI class and sends 
 * it to the Modellayer class and returns.
 * 
 * @author (dmab0913 gruppe ) 
 * @version (a version number or a date)
 */
public class ItemCtr
{
    private ItemContainer iCon;

    /**
     * Constructor for objects of class ItemCtr
     */
    public ItemCtr()
    {
        iCon = iCon.getInstance();
    }

    /**
     * controller deletes an item in the itemContainer
     */
    public void deleteItem(int itemId)
    {
        iCon.deleteItem(itemId);
    }

    /**
     * controller locates an item 
     */
    public Item findItem(int itemId)
    {
        return iCon.findItem(itemId);
    }

    /**
     * controller updates an Item
     */
    public void updateItem(int itemId, String description,int quantity, double pricePrPackage, int sizePrPackage, double pricePrItem, int locationNumber, int maxStock, int minStock)
    {
        iCon.updateItem(itemId, description, quantity, pricePrPackage, sizePrPackage, pricePrItem, locationNumber, maxStock, minStock);
    }

    /**
     * controller creates an item and stores it in the container
     */
    public void createItem(int itemId, String description, int quantity, double pricePrPackage, int sizePrPackage, double pricePrItem, int locationNumber, int maxStock, int minStock)
    {
        Item item = new Item(itemId, description, quantity, pricePrPackage, sizePrPackage, pricePrItem, locationNumber, maxStock, minStock);
        iCon.addItem(item);
    }

    /**
     * finds a item-object and uses a mutator method to set its description
     */
    public void setDescription(int itemId, String description)
    {
        iCon.findItem(itemId).setDescription(description);
    }

    /**
     * finds a item-object and uses a mutator method to set its quantity
     */
    public void setQuantity(int itemId, int quantity)
    {
        iCon.findItem(itemId).setQuantity(quantity);
    }

    /**
     * finds a item-object and uses a mutator method to set its pricePrPackage
     */
    public void setPricePrPackage(int itemId, double pricePrPackage)
    {
        iCon.findItem(itemId).setPricePrPackage(pricePrPackage);
    }

    /**
     * finds a item-object and uses a mutator method to set its sizePrPackage
     */
    public void setSizePrPackage(int itemId, int sizePrPackage)
    {
        iCon.findItem(itemId).setSizePrPackage(sizePrPackage);
    }

    /**
     * finds a item-object and uses a mutator method to set its pricePrItem
     */
    public void setPricePrItem(int itemId, double pricePrItem)
    {
        iCon.findItem(itemId).setPricePrItem(pricePrItem);
    }

    /**
     * finds a item-object and uses a mutator method to set its locationNumber
     */
    public void setLocationNumber(int itemId, int locationNumber)
    {
        iCon.findItem(itemId).setLocationNumber(locationNumber);
    }

    /**
     * finds a item-object and uses a mutator method to set its maxStock
     */
    public void setMaxStock(int itemId, int maxStock)
    {
        iCon.findItem(itemId).setMaxStock(maxStock);
    }

    /**
     * finds a item-object and uses a mutator method to set its minStock
     */
    public void setMinStock(int itemId, int minStock)
    {
        iCon.findItem(itemId).setMinStock(minStock);
    }
}
